package org.tech4j.common.core.sign.provider;

import com.google.common.collect.ImmutableMap;
import org.tech4j.common.core.sign.api.SignParameters;
import org.tech4j.common.core.sign.extractor.VersionOneExtractor;
import org.tech4j.common.core.sign.extractor.VersionTwoExtractor;

import java.util.Map;

/**
 * @program: tech4j-common
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/2 21:27
 **/
public class DefaultSignProvider implements SignProvider {

    private static final Map<String, SignProvider> VERSION_SIGN =
            ImmutableMap.of(
                    VersionOneExtractor.VERSION_1, new VersionOneSignProvider(),
                    VersionTwoExtractor.VERSION_2, new VersionTwoSignProvider()
            );

    @Override
    public String generateSign(final String signKey, final SignParameters signParameters) {
        return VERSION_SIGN.get(signParameters.getVersion())
                .generateSign(signKey, signParameters);
    }
}
